import requests
import pymongo
import json

def requestData():
    url = 'http://****.com/*.do'
    data = {
        'projectId': 90,
        'myTaskFlag': 1,
        'userId': 40
    }
    json_data = requests.post(url, data=json.dumps(data)).json()
    return json_data

def output_data(json_data):
    client = pymongo.MongoClient(host='localhost', port=27017)
    db = client.test
    collection = db.tasks
    tasks_data = json_data.get('taskList')
    collection.insert(tasks_data)
    client.close()

if __name__ == '__main__':
    json_data = requestData()
    output_data(json_data)
